import axios from 'axios'
export const getClassDetail = async(id)=>{
  return axios({
    url:'http://localhost:3000/classes/'+id
  })
}
export const iscollect = async(listid,userid)=>{
  return axios({
    url:'http://localhost:3000/collect',
    params:{
      userid:userid,
      collectid:listid
    }
  })
}
export const collect = async(listid,userid)=>{
 let res = await iscollect(listid,userid)
 if(res.data.length==0){
  return axios({
     url:'http://localhost:3000/collect',
     method:'post',
     data:{
       userid:userid,
       collectid:listid
     }
   })
 }else{
   console.log(res.data,'del');
  return axios({
    url:'http://localhost:3000/collect/'+res.data[0].id,
    method:'delete',
  })
 }
}

export const getArticleDetail = async(id)=>{
  return axios({
    url:'http://localhost:3000/articles/'+id
  })
}